package com.accesshollywood.grfxOrdering.orderTreeSpecial.nodes;

import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.tree.DefaultMutableTreeNode;

import com.accesshollywood.SQL.GFXSQL;
import com.accesshollywood.grfxOrdering.orderTreeSpecial.ApprPanel;
import com.accesshollywood.grfxOrdering.orderTreeSpecial.models.ApprTableModel;
import com.accesshollywood.indexables.GrfxOrder;

public class ApprTreeNode extends DefaultMutableTreeNode {
	/*
	public ApprTableModel model;
	public ApprPanel subPanel;

	public ApprTreeNode(GrfxOrder grfxOrderGroup) {
		model = new ApprTableModel(grfxOrderGroup);
	}

	public void adjPanel(JPanel panel, ApprTableModel currOrder) {
		int needsBitMask = 0;
		int apprBitMask = 0;

		apprBitMask = 	calcApprBitMask(currOrder);
		
		needsBitMask = 	calcNeedsBitMask(currOrder);

		subPanel = new ApprPanel(model, apprBitMask, needsBitMask, ApprPanel.VERBOSE);
		panel.add(subPanel);
	}
	
	public static int calcApprBitMask(ApprTableModel currOrder){
		int apprBitMask = 0;
		int a = ApprPanel.flagResearch;
		boolean b = currOrder.apprResearch();
		apprBitMask = ((currOrder.apprResearch()	? (apprBitMask | ApprPanel.flagResearch) 	: apprBitMask)) |
					  ((currOrder.apprPhotoEdit()	? (apprBitMask | ApprPanel.flagPhotoEdit) 	: apprBitMask)) |
					  ((currOrder.apprFootage()		? (apprBitMask | ApprPanel.flagFootage) 	: apprBitMask)) |
					  ((currOrder.apprLegal()		? (apprBitMask | ApprPanel.flagLegal) 		: apprBitMask));
		return apprBitMask;
	}
	
	public static int calcNeedsBitMask(ApprTableModel currOrder){
		int needsBitMask = 0;
		needsBitMask = 	((currOrder.needsResearch() ? (needsBitMask | ApprPanel.flagResearch)  : needsBitMask)) |
						((currOrder.needsPhotoEdit()? (needsBitMask | ApprPanel.flagPhotoEdit) : needsBitMask)) |
						((currOrder.needsFootage()	? (needsBitMask | ApprPanel.flagFootage)  : needsBitMask)) |
						((currOrder.needsLegal()	? (needsBitMask | ApprPanel.flagLegal) : needsBitMask));
		return needsBitMask;
	}
	
	public void setCheck(int apprBitMask, boolean state){
		if((apprBitMask & ApprPanel.flagResearch)!= 0){
			model.setApprResearch(state);
		}
		if((apprBitMask & ApprPanel.flagPhotoEdit)!= 0){
			model.setApprPhotoEdit(state);
		}
		if((apprBitMask & ApprPanel.flagFootage)!= 0){
			model.setApprFootage(state);
		}
		if((apprBitMask & ApprPanel.flagLegal)!= 0){
			model.setApprLegal(state);
		}
	}
	
	public class ApprItemListener implements ItemListener{
		int whichBitMask;
		
		public ApprItemListener(int bitMask){
			this.whichBitMask = bitMask;
		}
		@Override
		public void itemStateChanged(ItemEvent itemEvent) {
			setCheck(whichBitMask, ((JCheckBox)itemEvent.getItem()).isSelected());
			String field = "";
			if((whichBitMask & ApprPanel.flagResearch)!=0){
				field = "apprResearch";
			}
			if((whichBitMask & ApprPanel.flagPhotoEdit)!=0){
				field = "apprPhotoEdit";
			}
			if((whichBitMask & ApprPanel.flagFootage)!=0){
				field = "apprFootage";
			}
			if((whichBitMask & ApprPanel.flagLegal)!=0){
				field = "apprLegal";
			}
			GFXSQL.setAppr(model.grfxOrder,field, ((JCheckBox)itemEvent.getItem()).isSelected());
		}
	}
	*/
}
